package com.google.code.xconf.schema.definition.value.options;

import java.util.Set;

public abstract class OptionsList implements Options {

    protected abstract Set<String> getOptions();

    @Override
    public boolean matches(String value, boolean caseSensitive) {
        for (String option : getOptions()) {
            if (caseSensitive ? option.equals(value) : option.equalsIgnoreCase(value)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String toString() {
        String result = "";
        boolean first = true;
        for (String option : getOptions()) {
            result += !first ? ", " : "";
            result += option;
            if (first) {
                first = !first;
            }
        }
        return result;
    }


}
